#!/bin/bash
trap 'echo Abort ; exit 1' ERR

if [ $1 -a $1 == clean ] ; then 
	echo Clean AT91Bootstrap.
	rm Bootstrap-v1.13 -rf
	exit 0
fi

echo Build AT91Bootstrap.
if [ ! -d Bootstrap-v1.13 ] ; then
	unzip -q AT91Bootstrap1.13.zip
	( cd Bootstrap-v1.13 ; patch --silent -p1 < ../AT91Bootstrap1.13.patch )
fi
cd Bootstrap-v1.13/board/at91sam9263ek/dataflash/
make > /dev/null
cp dataflash_at91sam9263ek.bin /opt/armgcc/deploy/
